package br.com.mtech.ctrlliberty.ejb.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import br.com.mtech.ctrlliberty.clientjar.exception.BusinessException;

public class CryptographerUtil {

	public static String criptografar(String senha) throws BusinessException{
		
		String elementoCriptografado = null;
		
		try{
			MessageDigest md = MessageDigest.getInstance("MD5"); //MD5 ou SHA
			byte[] buf = senha.getBytes();
			md.update(buf);
			byte[] digest = md.digest();

			elementoCriptografado = new String(digest);


		} catch(NoSuchAlgorithmException nsae){
			throw new BusinessException(nsae);
		}
		return elementoCriptografado;
		
	}
	
}
